package controller

import (
	"github.com/gin-gonic/gin"
	"github.com/gomodule/redigo/redis"
	"root/consts"
	"root/utility"
)

type baseConfig struct {
	Host string `json:"host"`
	Img  string `json:"img"`
	UserAgreement string `json:"user_agreement"`
}


func GetBaseConfig(c *gin.Context)  {

	conn := utility.GetRedisConn()
	defer conn.Close()
	config, err := redis.String(conn.Do("GET",consts.SYSTEM_CONFIG))
	//fmt.Print(config)
	if err != nil {
		SendResponse(c, 500,"",nil)
		return
	}
	//json str 转map
	var data map[string]interface{}
	data ,err = utility.JsonToMap(config)
	conf := baseConfig{}
	conf.Host = data["host"].(string)
	conf.Img = data["img_path"].(string)
	conf.UserAgreement = data["user_agreement"].(string)

	SendResponse(c,200,"",conf)

}